Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay Ajax request for 0.5 seconds when performing a user search on stream plugin page #1082

Merged
merged 1 commit into from
Apr 19, 2020

Conversation

oscarssanchez
Copy link
Contributor

@oscarssanchez oscarssanchez commented Apr 19, 2020

Fixes #1081 .

Describe your approach and how it fixes the issue.

Hi @kasparsd, could you use this PR?

The solution proposed by @lkraav seems to be in line with select2 documentation: https://select2.org/data-sources/ajax#rate-limiting-requests

Alternatively, it looks like quietMillis could have been a good option to use per documentation https://select2.github.io/select2/ :

quietMillis int Number of milliseconds to wait for the user to stop typing before issuing the ajax request.

This didn't work for me however.

I'm wondering if this line should also be taken out since it looks it serves no purpose for now: https://github.com/xwp/stream/blob/develop/ui/js/admin.js#L72

As for the time window, 0.5 seconds seem to be the sweet spot for me.

Checklist

  • Project documentation has been updated to reflect the changes in this pull request, if applicable.
  • I have tested the changes in the local development environment (see contributing.md).
  • I have added phpunit tests.

Release Changelog

  • Fix: Describe a bug fix included in this release.
  • New: Describe a new feature in this release.

Release Checklist

  • This pull request is to the master branch.
  • Release version follows semantic versioning. Does it include breaking changes?
  • Update changelog in readme.txt.
  • Bump version in stream.php.
  • Bump Stable tag in readme.txt.
  • Bump version in classes/class-plugin.php.
  • Draft a release on GitHub.

Change [ ] to [x] to mark the items as done.

Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you so much @oscarssanchez!

@kasparsd kasparsd merged commit 9cb9807 into xwp:develop Apr 19, 2020
@kasparsd kasparsd added this to the Version 3.4.4 milestone Apr 19, 2020
@lkraav
Copy link
Contributor

lkraav commented Apr 19, 2020

Nice work. Maybe our select2 is too old to have quietMillis available? I can check on computer later.

@kasparsd
Copy link
Contributor

@lkraav Are you suggesting that the version of select2 bundled with Stream is too old for this flag to work?

@kasparsd kasparsd mentioned this pull request Jul 7, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.4.3: debounce AJAX select elements, avoid server overload - followup #1052
3 participants